<template>
    <div>
        <el-table
            :data="wordList"
            stripe
            style="width: 100%"
            @row-click="goDetail"
            >
            <el-table-column
            prop="title"
            label="标题"
            width="180">
            </el-table-column>
            <el-table-column
            label="归属"
            width="180">
                <template  slot-scope="scope">{{scope.row.username}}/{{scope.row.storeTitle}}</template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                    size="mini"
                    @click="handleEdit(scope.row)">编辑</el-button>
                    <el-button
                    size="mini"
                    type="danger"
                    @click="handleDelete(scope.row.id)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
import $api from '../../../api/index'
export default {
    data(){
        return {
            wordList:[]
        }
    },
    created(){
        $api.getWordList().then(res => {
            if(res.code === 1){
                this.wordList = res.data;
            }
        })
    },
    methods:{
        handleEdit(row){
            //编辑
            localStorage.setItem("editWord",JSON.stringify(row));
            this.$router.push('/main/addWord');
        },
        handleDelete(){
            //删除
        },
        goDetail(row){
            this.$router.push({path:'/main/detail',query:{id:row.s_id}})
        }
    }
}
</script>
